package v1

import (
	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/do"

	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/entity"

	"github.com/gogf/gf/v2/frame/g"
)

// req and resp struct
type ListReq struct {
	g.Meta `path:"/tenants" tags:"租户管理" method:"get" summary:"租户列表"`
	Code   string `json:"code" description:"租户编码"`
	Status *bool  `json:"status"     description:"状态: 启用1和禁用0"`
	Name   string `json:"name"        description:"租户名称"`
	Page   int    `json:"page"   v:"required|min:1"     description:"页码"`
	Size   int    `json:"size" v:"required|between:1,100"       description:"每页条数"`
}
type ListRes struct {
	g.Meta `mime:"application/json"`
	Data   []Tenant `json:"data" description:"租户列表"`
	Total  int      `json:"total"        description:"总条数"`
}
type AddReq struct {
	g.Meta       `path:"/tenants" tags:"租户管理" method:"post" summary:"添加租户"`
	Code         string `json:"code" v:"required|regex:^[0-9]{6}$" description:"租户编码"`
	Name         string `json:"name"       description:"租户名称"`
	CountryCode  string `json:"countryCode"    description:"国家"`
	ProvinceCode string `json:"provinceCode"   description:"省份"`
	CityCode     string `json:"cityCode"       description:"城市"`
	CountyCode   string `json:"countyCode"     description:"区县"`
	Address      string `json:"address"    description:"地址"`
	Contact      string `json:"contact"    description:"联系人"`
	Phone        string `json:"phone" v:"phone"     description:"联系电话"`
}
type AddRes struct {
	g.Meta `mime:"application/json"`
	Id     int64 `json:"id" description:"新增租户id"`
}
type UpdateReq struct {
	g.Meta       `path:"/tenants/{id}" tags:"租户管理" method:"put" summary:"更新租户"`
	Id           int    `query:"id" v:"required|min:1"`
	Name         string `json:"name"       description:"租户名称"`
	Status       bool   `json:"status"        description:"状态: 启用1和禁用0"`
	CountryCode  string `json:"countryCode"    description:"国家"`
	ProvinceCode string `json:"provinceCode"   description:"省份"`
	CityCode     string `json:"cityCode"       description:"城市"`
	CountyCode   string `json:"countyCode"     description:"区县"`
	Address      string `json:"address"    description:"地址"`
	Contact      string `json:"contact"    description:"联系人"`
	Phone        string `json:"phone"      description:"联系电话"`
}
type UpdateRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"修改成功的行数"`
}
type DeleteReq struct {
	g.Meta `path:"/tenants/{id}" tags:"租户管理" method:"delete" summary:"删除租户"`
	Id     int64 `query:"id" v:"required|min:1"`
}
type DeleteRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"删除成功的行数"`
}
type InfoReq struct {
	g.Meta `path:"/tenants/{id}" tags:"租户管理" method:"get" summary:"租户详情"`
	Id     int64 `query:"id" v:"required|min:1"`
}
type InfoRes struct {
	g.Meta `mime:"application/json"`
}

type Tenant struct {
	Id           int64  `json:"id"         dc:""`
	Code         string `json:"code" dc:"租户编码"`
	Name         string `json:"name"       description:"租户名称"`
	Status       bool   `json:"status"     description:"状态: 启用1和禁用0"`
	CountryCode  string `json:"countryCode"    description:"国家编码"`
	ProvinceCode string `json:"provinceCode"   description:"省编码"`
	CityCode     string `json:"cityCode"       description:"城市编码"`
	CountyCode   string `json:"countyCode"       description:"区县编码"`
	Address      string `json:"address"     description:"地址"`
	Contact      string `json:"contact"    description:"联系人"`
	Phone        string `json:"phone"      description:"联系电话"`
}

// input and output struct
type ListInput struct {
	Code   string `json:"code" description:"租户编码"`
	Status *bool  `json:"status"      description:"状态: 启用1和禁用0"`
	Name   string `json:"name"        description:"租户名称"`
	Page   int    `json:"page"        description:"页码"`
	Size   int    `json:"size"        description:"每页条数"`
}
type ListOutput struct {
	Data  []entity.Tenant `json:"data" description:"租户列表"`
	Total int             `json:"total"        description:"总条数"`
}
type AddInput struct {
	do.Tenant
}
type AddOutput struct {
	Id int64 `json:"id" description:"修改成功的行数"`
}
type UpdateInput struct {
	do.Tenant
}
type UpdateOutput struct {
	Rows int64 `json:"rows" description:"修改成功的行数"`
}
type DeleteInput struct {
	Id int64 `json:"id" description:"租户ID"`
}
type DeleteOutput struct {
	Rows int64 `json:"rows" description:"删除成功的行数"`
}
type InfoInput struct {
	Id int64 `json:"id" description:"租户ID"`
}
type InfoOutput struct {
	Tenant
	Address string `json:"address" description:"地址"`
}
